package com.blue.gateway.client.strategy;

import com.alibaba.fastjson.JSON;
import com.blue.common.enums.ServiceEnum;
import com.blue.user.model.entity.CommonUserInfo;
import com.blue.user.model.entity.WeChatLoginUserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 微信端后台服务的用户解析策略
 *
 * @author liulei
 * @version 1.0
 */
@Slf4j
@Component
public class WeChatGetUserStrategy extends AbstractStrategyGetLoginUser {

    @Override
    public boolean support(ServiceEnum systemType) {
        return ServiceEnum.WE_CHAT.equals(systemType);
    }

    @Override
    public CommonUserInfo parseJsonStr2UserInfo(String userJson) {
        log.info("解析微信小程序后台系统---用户登录信息...");
        // 调用小程序的接口，根据token解析用户信息
        return JSON.parseObject(userJson, WeChatLoginUserInfo.class);
    }

}
